<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>项目款项-目的地运营集团数据管理平台</title>
<include file="Include:style" />
<link rel="stylesheet" href="__PUBLIC__/mobile/css/dropload.css">
</head>
<body style="background: #f3f3f3;">
<div class="header" style="line-height:0">
	<a href="__APP__/Mobile/Index/index" class="back_btn"></a>
    <a class="project_menu project_menu_l <if condition='$mode eq 1'>active</if>" href="__APP__/Mobile/Financial/project_funds/keyword/{$keyword}/mode/1/center_id/{$center_id}/type/{$type}/ptype/{$ptype}">按单据</a><a class="project_menu project_menu_r <if condition='$mode eq 2'>active</if>" href="__APP__/Mobile/Financial/project_funds/keyword/{$keyword}/mode/2/center_id/{$center_id}/type/{$type}/ptype/{$ptype}">按项目</a>
    <a href="javascript:;" class="header_txt_btn project_search"></a>
</div>
<div class="select_menu">
    <div class="classify clearboth w3">
        <a href="javascript:;"><span><if condition="$center_id eq -10">所属中心<else />{$center_name}</if></span></a><a href="javascript:;"><span><if condition="$ptype eq -10">项目类型<else /><if condition="$ptype_name_length gt 4">{:msubstr($ptype_name,0,4)}<else />{$ptype_name}</if></if></span></a></a><a href="javascript:;"><span><if condition="$type eq -10">开票/收款<elseif condition="$type eq 1"/>开票<else />收款</if></span></a>
    </div>
    <div class="btn_box">
        <ul>
            <foreach name="pro_list" item="vo">
                <li <if condition="$center_id eq $vo['name2']">class="active"</if>>
                <a class="clear_storage" href="__APP__/Mobile/Financial/project_funds/keyword/{$keyword}/mode/{$mode}/center_id/{$vo['name2']}/type/{$type}/ptype/{$ptype}">{$vo['name5']}</a>
                </li>
            </foreach>
        </ul>
        <ul>
            <li <if condition="$ptype eq -10">class="active"</if>>
            <a class="clear_storage" href="__APP__/Mobile/Financial/project_funds/keyword/{$keyword}/mode/{$mode}/center_id/{$center_id}/type/{$type}/ptype/-10">项目类型</a>
            </li>
            <foreach name="ptype_list" item="vo">
                <li <if condition="$ptype eq $vo['id']">class="active"</if>>
                <a class="clear_storage" href="__APP__/Mobile/Financial/project_funds/keyword/{$keyword}/mode/{$mode}/center_id/{$center_id}/type/{$type}/ptype/{$vo['id']}">{$vo['second_name']}</a>
                </li>
            </foreach>
        </ul>
        <ul>
            <li <if condition="$type eq -10">class="active"</if>>
            <a class="clear_storage" href="__APP__/Mobile/Financial/project_funds/keyword/{$keyword}/mode/{$mode}/center_id/{$center_id}/type/-10/ptype/{$ptype}">开票/收款</a>
            </li>
            <li <if condition="$type eq 1">class="active"</if>>
            <a class="clear_storage" href="__APP__/Mobile/Financial/project_funds/keyword/{$keyword}/mode/{$mode}/center_id/{$center_id}/type/1/ptype/{$ptype}">开票</a>
            </li>
            <li <if condition="$type eq 2">class="active"</if>>
            <a class="clear_storage" href="__APP__/Mobile/Financial/project_funds/keyword/{$keyword}/mode/{$mode}/center_id/{$center_id}/type/2/ptype/{$ptype}">收款</a>
            </li>
        </ul>
    </div>
</div>
<div class="content">
    <div class="financial_list">
        <ul>
            <foreach name="result" item="vo">
                <if condition="$mode eq 1">
                    <li <if condition="$vo['tid'] eq NULL">class="blue"</if>>
                        <a href="__APP__/Mobile/Financial/project_funds_detail_dj/id/{$vo['id']}/fid/{$vo['fid']}/tid/{$vo['tid']}/sid/{$vo['sid']}/keyword/{$keyword}/mode/{$mode}/center_id/{$center_id}/type/{$type}/ptype/{$ptype}">
                            <span class="tit">{$vo['project_num']}  <i>|</i>  {$vo['p_typen']}</span>
                            <p>{$vo['project_name']}<em>第{$vo['stage']}阶段</em></p>

                            <if condition="$vo['tid'] eq NULL">
                                <table>
                                    <tr>
                                        <th>已开票金额</th>
                                        <th>已开票日期</th>
                                        <th>已收款金额</th>
                                        <th>已收款日期</th>
                                    </tr>
                                    <tr>
                                        <td>{$vo['fmoney']+0}</td>
                                        <td>{$vo['fdate']}</td>
                                        <td>{$vo['money']+0}</td>
                                        <td>{$vo['date']}</td>
                                    </tr>
                                </table>
                                    <div class="last">
                                        剩余应收款金额  <em>{$vo['syysk']}</em> <span>{$vo['add_user']}({$vo['add_date']|substr=0,10})</span>
                                    </div>
                                    <else />
                                <table>
                                    <tr>
                                        <th>应开票金额</th>
                                        <th>应开票日期</th>
                                        <th>已开票金额</th>
                                        <th>已开票日期</th>
                                    </tr>
                                    <tr>
                                        <td>{$vo['ticket_money']+0}</td>
                                        <td>{$vo['ticket_date']}</td>
                                        <td>{$vo['fmoney']+0}</td>
                                        <td>{$vo['fdate']}</td>
                                    </tr>
                                </table>
                                <div class="last">
                                    剩余应开票金额  <em>{$vo['syykp']}</em> <span>{$vo['add_user']}({$vo['add_date']|substr=0,10})</span>
                                </div>
                            </if>


                        </a>
                    </li>
                    <else />
                    <li>
                        <a href="__APP__/Mobile/Financial/project_funds_detail_xm/id/{$vo['id']}/keyword/{$keyword}/mode/{$mode}/center_id/{$center_id}/type/{$type}/ptype/{$ptype}/form/funds">
                            <span class="tit">{$vo['project_num']}  <i>|</i>  {$vo['p_typen']}</span>
                            <p>{$vo['project_name']}</p>
                            <div class="last">
                                合同金额  <em>{$vo['contract_money']}</em> <span>{$vo['add_user']}({$vo['add_date']|substr=0,10})</span>
                            </div>
                        </a>
                    </li>
                </if>
            </foreach>
        </ul>
    </div>
</div>
<div class="Mask item_mask"></div>
<!-- 弹框 -->
<div class="search_fix">
    <div class="search_header">
        <a class="back_btn" href="javascript:;"></a>
        <input class="project_search_inp" type="text" value="{$keyword}" placeholder="输入搜索内容…">
        <a href="javascript:;" class="header_txt_btn jd_up">搜索</a>
    </div>
    <div class="form_item">
        <div class="form_item_tit">
            搜索推荐
        </div>
        <div class="form_item_box search_btn_box">
			<if condition="$result_t eq ''">暂无相关内容</if>
			<foreach name="result_t" item="vo">
            <a href="__APP__/Mobile/Financial/project_funds/keyword/{$vo['keyword']}/mode/{$mode}/center_id/{$center_id}/type/{$type}/ptype/{$ptype}">{:msubstr($vo['keyword'],0,6,'utf-8',false)}</a>
			</foreach>
        </div>
        <div class="form_item_tit">
            搜索历史
        </div>
        <div class="form_item_box search_list_box">
            <if condition="$result_l eq ''">
                <p style="padding:7px 0">暂无相关内容</p>
            <else />
                <ul>
                    <foreach name="result_l" item="vo">
                    <li><a href="__APP__/Mobile/Financial/project_funds/keyword/{$vo['keyword']}/mode/{$mode}/center_id/{$center_id}/type/{$type}/ptype/{$ptype}">{$vo['keyword']}</a></li>
                    </foreach>
                </ul>
                <div class="clear">清空搜索历史</div>
            </if>
        </div>
    </div>
</div>
<include file="Include:javascript" />
<script src="__PUBLIC__/mobile/js/dropload.min.js"></script>
<script>
    $('.select_menu .classify a').each(function(i){
        var _this = $(this);
        _this.click(function(){
            if(_this.hasClass('active')){
                _this.removeClass('active');
                $('.select_menu ul').removeClass('active');
                $('.select_menu .btn_box').css('height','0');
                $('.item_mask').fadeOut();
            }else{
                var hei = $('.select_menu ul').eq(i).height()+20;
                _this.addClass('active').siblings().removeClass('active');
                $('.select_menu ul').eq(i).addClass('active').siblings().removeClass('active');
                $('.select_menu .btn_box').css('height',hei);
                $('.item_mask').fadeIn();
            }
        })
    })

    $('.item_mask').on('touchstart',function(){
        $('.select_menu .classify a,.select_menu ul').removeClass('active');
        $('.select_menu .btn_box').css('height','0');
        $('.item_mask').fadeOut();
    })
    //搜索
    $('.project_search').click(function(){
        $('.search_fix').fadeIn();
        $('html').addClass('active');
    })
    $('.back_btn').click(function(){
        $('.search_fix').fadeOut();
        $('html').removeClass('active');
    })
    $('.jd_up').click(function(){
        sessionStorage.clear();
        var val = $('.project_search_inp').val();
        location.href="__APP__/Mobile/Financial/project_funds/keyword/"+val+"/mode/{$mode}/center_id/{$center_id}/type/{$type}/ptype/{$ptype}";
    })
    $('.clear').click(function(){
        $.ajax({
            type: 'POST',
            async:false,
            dataType:"json",
            data:{"center_id":130010},
            url:"__APP__/Mobile/Financial/project_funds_del",
            dataType: 'json',
            success: function(data){
                $('.search_list_box').html("<p style='padding:7px 0'>暂无相关内容</p>");
            }
        })
    })


    var center_id = "{$center_id}";
    $(".clear_storage,.project_menu,.search_btn_box a,.search_list_box a,.back_btn").click(function(){sessionStorage.clear();});

    $(function(){
        var $now = 1;
        //输出本地存储now
        var $storage_now = sessionStorage.getItem("storage_now");
        if($storage_now){
            $now = parseInt($storage_now);
        }
        var page = 6,
            $count = "{$count}",
            max = Math.ceil(parseInt($count)/page);

        $('.content').dropload({
            scrollArea : window,
            loadDownFn : function(me){
                if($now<max){
                    var type = "{$type}",
                        keyword = "{$keyword}",
                        mode = "{$mode}",
                        center_id = "{$center_id}",
                        ptype = "{$ptype}",
                        $start_count = page*$now,
                        html='';
                    $.ajax({
                        type: 'POST',
                        async:false,
				        dataType:"json",
                        data:{"keyword":keyword,"mode":mode,"center_id":center_id,"type":type,"start_size":$start_count,"start_page":page},
                        url:"__APP__/Mobile/Financial/project_funds_ajax",
                        dataType: 'json',
                        success: function(data){
                            if(data){
                                for(var i=0; i<data.length; i++){
                                    if(mode==1){
                                        if(data[i].tid){
                                            html += '<li>';
                                        }else{
                                            html += '<li class="blue">';
                                        }
                                        html += '<a href="__APP__/Mobile/Financial/project_funds_detail_dj/id/'+data[i].id+'/fid/'+data[i].fid+'/tid/'+(data[i].tid?data[i].tid:'')+'/sid/'+(data[i].sid?data[i].sid:'')+'/keyword/{$keyword}/mode/{$mode}/center_id/{$center_id}/type/{$type}/ptype/{$ptype}">';
                                        html += '<span class="tit">'+data[i].project_num+'  <i>|</i>  '+data[i].p_typen+'</span>';
                                        html += '<p>'+data[i].project_name+'<em>第'+data[i].stage+'阶段</em></p>';
                                        if(data[i].tid){
                                            html += '<table><tr><th>应开票金额</th><th>应开票日期</th><th>已开票金额</th><th>已开票日期</th></tr><tr>';
                                            html += '<td>'+data[i].ticket_money+'</td>';
                                            html += '<td>'+data[i].ticket_date+'</td>';
                                            html += '<td>'+data[i].fmoney+'</td>';
                                            html += '<td>'+data[i].fdate+'</td>';
                                            html += '</tr></table><div class="last"> ';
                                            html += '剩余应开票金额  <em>'+(data[i].syykp||data[i].syykp==0?data[i].syykp:'')+'</em> <span>'+data[i].add_user+'('+data[i].add_date.substring(0,10)+')</span>';
                                        }else{
                                            html += '<table><tr><th>已开票金额</th><th>已开票日期</th><th>已收款金额</th><th>已收款日期</th></tr><tr>';
                                            html += '<td>'+data[i].fmoney+'</td>';
                                            html += '<td>'+data[i].fdate+'</td>';
                                            html += '<td>'+data[i].money+'</td>';
                                            html += '<td>'+data[i].date+'</td>';
                                            html += '</tr></table><div class="last"> ';
                                            html += '剩余应收款金额  <em>'+(data[i].syysk||data[i].syysk==0?data[i].syysk:'')+'</em> <span>'+data[i].add_user+'('+data[i].add_date.substring(0,10)+')</span>';
                                        }
                                    }else{
                                        html += '<li>';
                                        html += '<a href="__APP__/Mobile/Financial/project_funds_detail_xm/id/'+data[i].id+'/keyword/{$keyword}/mode/{$mode}/center_id/{$center_id}/type/{$type}/ptype/{$ptype}/form/funds">';
                                        html += '<span class="tit">'+data[i].project_num+'  <i>|</i>  '+data[i].p_typen+'</span>';
                                        html += '<p>'+data[i].project_name+'</p>';
                                        html += ' <div class="last">';
                                        html += '合同金额  <em>'+data[i].contract_money+'</em> <span>'+data[i].add_user+'('+data[i].add_date.substring(0,10)+')</span>';
                                        html += '</div>';
                                        html += '</a>';
                                    }
                                    html += '</li>';
                                }
                            }
                            $now++;
                            //保存本地存储
                            var $get_str_after = sessionStorage.getItem("storage_str"),
                                $storage_str = "";

                            if($get_str_after){
                                $storage_str += $get_str_after.replace(/^\[|\]$/g,"")+",";
                            }
                            $storage_str += JSON.stringify(data).replace(/^\[|\]$/g,"");
                            $storage_str = "["+$storage_str+"]";
                            sessionStorage.setItem("storage_str",$storage_str);
                            sessionStorage.setItem("storage_now",$now);
                            $('.financial_list ul').append(html);
                            me.resetload();
                        },
                        error: function(xhr, type){
                            alert('Ajax error!');
                            // 即使加载出错，也得重置
                            me.resetload();
                        }
                    });
                }else{
                    me.lock();
                    me.noData();
                    me.resetload();
                }
            }
            
        });
        
    })
    $(window).scroll(function(){
        //保存滚动条位置
        var $storage_top = $(window).scrollTop();
        sessionStorage.setItem("storage_top",$storage_top);
    });
    $(function(){
        var $get_str_before = sessionStorage.getItem("storage_str"),
            $storage_top = sessionStorage.getItem("storage_top");

        if($get_str_before){
            var data = JSON.parse($get_str_before),
                    type = "{$type}",
                    keyword = "{$keyword}",
                    mode = "{$mode}",
                    center_id = "{$center_id}",
                    ptype = "{$ptype}",
                    html='';
            for(var i=0; i<data.length; i++){
                if(mode==1){
                    if(data[i].tid){
                        html += '<li>';
                    }else{
                        html += '<li class="blue">';
                    }
                    html += '<a href="__APP__/Mobile/Financial/project_funds_detail_dj/id/'+data[i].id+'/fid/'+data[i].fid+'/tid/'+(data[i].tid?data[i].tid:'')+'/sid/'+(data[i].sid?data[i].sid:'')+'/keyword/{$keyword}/mode/{$mode}/center_id/{$center_id}/type/{$type}/ptype/{$ptype}">';
                    html += '<span class="tit">'+data[i].project_num+'  <i>|</i>  '+data[i].p_typen+'</span>';
                    html += '<p>'+data[i].project_name+'<em>第'+data[i].stage+'阶段</em></p>';
                    if(data[i].tid){
                        html += '<table><tr><th>应开票金额</th><th>应开票日期</th><th>已开票金额</th><th>已开票日期</th></tr><tr>';
                        html += '<td>'+data[i].ticket_money+'</td>';
                        html += '<td>'+data[i].ticket_date+'</td>';
                        html += '<td>'+data[i].fmoney+'</td>';
                        html += '<td>'+data[i].fdate+'</td>';
                        html += '</tr></table><div class="last"> ';
                        html += '剩余应开票金额  <em>'+(data[i].syykp||data[i].syykp==0?data[i].syykp:'')+'</em> <span>'+data[i].add_user+'('+data[i].add_date.substring(0,10)+')</span>';
                    }else{
                        html += '<table><tr><th>已开票金额</th><th>已开票日期</th><th>已收款金额</th><th>已收款日期</th></tr><tr>';
                        html += '<td>'+data[i].fmoney+'</td>';
                        html += '<td>'+data[i].fdate+'</td>';
                        html += '<td>'+data[i].money+'</td>';
                        html += '<td>'+data[i].date+'</td>';
                        html += '</tr></table><div class="last"> ';
                        html += '剩余应收款金额  <em>'+(data[i].syysk||data[i].syysk==0?data[i].syysk:'')+'</em> <span>'+data[i].add_user+'('+data[i].add_date.substring(0,10)+')</span>';
                    }
                }else{
                    html += '<li>';
                    html += '<a href="__APP__/Mobile/Financial/project_funds_detail_xm/id/'+data[i].id+'/keyword/{$keyword}/mode/{$mode}/center_id/{$center_id}/type/{$type}/ptype/{$ptype}/form/funds">';
                    html += '<span class="tit">'+data[i].project_num+'  <i>|</i>  '+data[i].p_typen+'</span>';
                    html += '<p>'+data[i].project_name+'</p>';
                    html += ' <div class="last">';
                    html += '合同金额  <em>'+data[i].contract_money+'</em> <span>'+data[i].add_user+'('+data[i].add_date.substring(0,10)+')</span>';
                    html += '</div>';
                    html += '</a>';
                }
                html += '</li>';
            }
            $('.financial_list ul').append(html);
        }
        if($storage_top){
            $(window).scrollTop($storage_top);
        }
    })
</script>
</body>
</html>